package com.aidong.login.biz.impl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.aidong.login.biz.MemberLoginBiz;
import com.aidong.login.dao.MemberLoginDao;
import com.aidong.login.entity.Member;
import com.aidong.login.entity.MemberBase;

@Service("memberLoginBiz")
public class MemberLoginBizImpl implements MemberLoginBiz {

	private MemberLoginDao memberLoginDao;
	
	@Autowired
	public void setMemberLoginDao(MemberLoginDao memberLoginDao) {
		this.memberLoginDao = memberLoginDao;
	}

	/**
	 * 手机号码登录
	 * @param member
	 */
	@Override
	public Map<String, Object> getPhoneToLogin(String phoneNo) {
		return memberLoginDao.getPhoneToLogin(phoneNo);
	}

	/**
	 * 无密码快捷登陆
	 * @param phoneNo
	 * @return
	 */
	@Override
	public Map<String, Object> getNotPasswordLogin(String phoneNo) {
		return memberLoginDao.getNotPasswordLogin(phoneNo);
	}

	/**
	 * 第三方登录
	 */
	/*@Override
	public int addThirdPartyLogin(Member member) {
		return memberLoginDao.addThirdPartyLogin(member);
	}*/

	@Override
	public int addThirdPartyLoginQqNumber(Member member) {
		// TODO Auto-generated method stub
		return memberLoginDao.addThirdPartyLoginQqNumber(member);
	}

	@Override
	public int addThirdPartyLoginWeiBo(Member member) {
		// TODO Auto-generated method stub
		return memberLoginDao.addThirdPartyLoginWeiBo(member);
	}

	@Override
	public int addThirdPartyLoginWeChat(Member member) {
		// TODO Auto-generated method stub
		return memberLoginDao.addThirdPartyLoginWeChat(member);
	}
	
	/**
	 * 第三方账号是否已经注册为爱动号会员
	 * @param map
	 * @return
	 */
	@Override
	public int getIfThirdRegisterd(Map<String, Object> map) {
		return memberLoginDao.getIfThirdRegisterd(map);
	}

	/**
	 * 根据第三方账号获得爱动号
	 * @param map
	 * @return
	 */
	@Override
	public String getThirdByIdongId(Map<String, Object> map) {
		return memberLoginDao.getThirdByIdongId(map);
	}

	/**
	 * 无密码快捷注册
	 * @param map
	 * @return
	 */
	@Override
	public int addNotPassRegister(Map<String, Object> map) {
		return memberLoginDao.addNotPassRegister(map);
	}

	/**
	 * 获得头像
	 */
	@Override
	public String getThirdHeadUrl(String idongId) {
		return memberLoginDao.getThirdHeadUrl(idongId);
	}

	/**
	 * 记录登陆信息
	 */
	@Override
	public void editMemberLoginMsg(Member member) {
		String phoneType = member.getPhoneType();
		if("android".equalsIgnoreCase(phoneType)){
			phoneType = "1";
		}
		if("ios".equalsIgnoreCase(phoneType)){
			phoneType = "2";
		}
		member.setPhoneType(phoneType);
		memberLoginDao.editMemberLoginMsg(member);
	}

	/**
	 * 检查用户资料是否完善 
	 */
	@Override
	public MemberBase getCheckMemberData(int idongId) {
		return memberLoginDao.getCheckMemberData(idongId);
	}

}
